#include<bits/stdc++.h>
using namespace std;
int n, m, l, T;
double vv;
int a[100010], d[100010], v[100010], p[100010];
const double eps = 1e-3;
bool cmp(pair<int, int> a, pair<int, int> b){
    if(a.second != b.second)  return a.second < b.second;
    return a.first < b.first;
}
bool check(int x){
    if(a[x] < 0){
        int k = lower_bound(p+1, p+m+1, d[x])-p;
        int s = p[k] - d[x];
        double speed = sqrt(1.0*v[x]*v[x]+2.0*a[x]*s);
        if(speed-eps > vv) return 1;
        return 0;
    }
    if(a[x] == 0 && v[x] > vv) return 1;
    if(d[x] > p[m]) return 0;
    int s = p[m] - d[x];
    double speed = sqrt(1.0*v[x]*v[x] + 2*a[x]*s);
    if(speed-eps > vv) return 1;
    return 0;
}
pair<int, int> f(int x){
    if(a[x] == 0) return {d[x], l};
    double dis = 1.0*vv*vv - 1.0 * v[x] * v[x];
    dis /= 2.0*a[x];
    if(dis < 0) dis = 0;
    if(a[x] >= 0) return{d[x] + floor(dis), l};
    return {d[x], d[x] + ceil(dis)};
}
void solve(){
    vector<pair<int, int> > seg;
    cin >> n >> m >> l >> vv;
    int cnt = 0;
    for(int i = 1; i <= n; i++) cin >> d[i] >> v[i] >> a[i];
    for(int i = 1; i <= m; i++) cin >> p[i];
    for(int i = 1; i <= n; i++){
        if(check(i)){
            cnt++;
            seg.push_back(f(i));
//            cout << i << ' ' << f(i).first << ' ' << f(i).second << endl;
        }
    }
    sort(seg.begin(), seg.end(), cmp);
    int k = 0, ans = 0;
//    for(int i = 0; i < cnt; i++) cout << seg[i].first << " " << seg[i].second << endl;
    for(int i = 0; i < cnt; i++){
        if(seg[i].first <= p[k]) continue;
        k = upper_bound(p+1, p+m+1, seg[i].second-1) -p-1;
        ans++;
    }
    cout << cnt << " " << m-ans << endl;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> T;
    while(T--) solve();
    return 0;
}
//sigma n = 2e6
//nt = 2e6